package edu.pku.sei.modeler.model.notation.core;

import java.util.Hashtable;

import edu.pku.sei.modeler.model.core.MetaModelElement;


public class LayoutNode {
	static public final int TYPE_NONE=0;
	static public final int TYPE_VERTICAL_FLOW=1;
	static public final int TYPE_HORIZONTAL_FLOW=2;
	static public final int TYPE_BORDER=3;
	static public final int TYPE_VECTORGRAPH=4;
	static public final int TYPE_FREEDOM=5;
	public void fireChanges(){
		refHost.firePropertyChange(ShapeConstance.REFRESH_VIEW, null, null);
	}
	@SuppressWarnings("unchecked")
	protected LayoutNode(MetaModelElement host){
		refHost=host;
		mapConstraints=new Hashtable();
		setLayoutStrategy(TYPE_NONE);
	}
	public void putConstraint(Object key,Object data){
		try {
			mapConstraints.put(key, data);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	public Object getConstraint(Object key){
		return mapConstraints.get(key);
	}
	public void removeConstraint(Object key){
		mapConstraints.remove(key);
	}
	public void clearConstraint(){
		mapConstraints.clear();
	}
	
	public void setLayoutStrategy(int layoutStrategy) {
		this.layoutStrategy = layoutStrategy;
		clearConstraint();
	}
	public int getLayoutStrategy() {
		return layoutStrategy;
	}

	public MetaModelElement getHost() {
		return refHost;
	}

	//reference
	private MetaModelElement refHost;
	//entity
	private Hashtable mapConstraints;
	
	private int layoutStrategy;
}
